package com.blb.educourseservice.service;

import com.blb.educourseservice.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class MQService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 事务的测试
     */
    @Transactional
    public void test(){
        rabbitTemplate.convertAndSend("exchange_1","world.xxx","Error!!!!" + new Date());
//        int x = 10 / 0;
    }
}
